{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/earthquake\n",
      "100000 000003.0011 002289.0224\n",
      "<HDF5 dataset \"000001.0004\": shape (9000, 3), type \"<i4\">\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from os import path\n",
    "import h5py\n",
    "\n",
    "# 读取数据集\n",
    "dataset_path = \"E:/RealSeisData/Diting50hz/\"\n",
    "fname = \"DiTing330km_part_0.hdf5\"\n",
    "hdf5_path = path.join(dataset_path, fname)\n",
    "\n",
    "f=h5py.File(hdf5_path,\"r\")\n",
    "for key in f.keys():\n",
    "    print(f[key].name)\n",
    "\n",
    "group = f['/earthquake']\n",
    "# 打印这个part的keys\n",
    "keys = list(group.keys())\n",
    "print(len(keys), keys[10], keys[10000])\n",
    "# 打印一个数据\n",
    "data = f.get('earthquake/000001.0004')\n",
    "print(data)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "163      NaN\n",
      "447      NaN\n",
      "528      NaN\n",
      "590      NaN\n",
      "711      NaN\n",
      "          ..\n",
      "135979   NaN\n",
      "136080   NaN\n",
      "136083   NaN\n",
      "136131   NaN\n",
      "136186   NaN\n",
      "Name: st_mag, Length: 2857, dtype: float64\n"
     ]
    }
   ],
   "source": [
    "from tqdm import tqdm\n",
    "dataset_path = \"E:/RealSeisData/Diting50hz/\"\n",
    "fname = \"DiTing330km_test.csv\"\n",
    "fpath=path.join(dataset_path,fname)\n",
    "csv=pd.read_csv(fpath)\n",
    "# print(csv.info)\n",
    "\n",
    "# 找到不是数的\n",
    "non_float_rows = csv[csv.iloc[:, 14].apply(pd.to_numeric, errors='coerce').isna()]\n",
    "\n",
    "# 打印这些元素所在的行\n",
    "print(non_float_rows.iloc[:, 14])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "removed 10535 rows with s-p<40\n",
      "removed 24 rows with p or s <=100\n",
      "removed 4 rows with s >= 8900\n",
      "adjust rows with non-float st_mag\n"
     ]
    }
   ],
   "source": [
    "#清洗数据\n",
    "file_path = path.join(dataset_path, \"DiTing330km_total.csv\")\n",
    "csv = pd.read_csv(file_path, low_memory=False)\n",
    "\n",
    "oldnum = csv.shape[0]\n",
    "csv=csv[csv['s_pick']-csv['p_pick']>=40]\n",
    "newnum=csv.shape[0]\n",
    "print('removed', oldnum-newnum, 'rows with s-p<40')\n",
    "\n",
    "oldnum = csv.shape[0]\n",
    "csv = csv[csv['p_pick'] > 100]\n",
    "csv = csv[csv['s_pick'] > 100]\n",
    "newnum = csv.shape[0]\n",
    "print('removed', oldnum-newnum, 'rows with p or s <=100')\n",
    "\n",
    "oldnum = csv.shape[0]\n",
    "csv = csv[csv['s_pick'] < 8900]\n",
    "newnum = csv.shape[0]\n",
    "print('removed', oldnum-newnum, 'rows with s >= 8900')\n",
    "\n",
    "csv['st_mag'] = pd.to_numeric(csv['st_mag'], errors='coerce')\n",
    "csv.loc[csv['st_mag'].isna(), 'col14'] = -99\n",
    "print('adjust rows with non-float st_mag')\n",
    "\n",
    "#存入csv\n",
    "file_path = path.join(dataset_path, \"DiTing330km_total_wash.csv\")\n",
    "csv.to_csv(file_path)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "\n",
    "# 将csv文件按照指定比例划分为训练集和测试集，并将结果存储到两个新的csv文件中\n",
    "def split_csv(csv, train_ratio=0.9, seed=1998):\n",
    "    # 将数据集划分为训练集和测试集，其中train_ratio表示训练集占总数据的比例，random_state表示随机数种子\n",
    "    train_data, testval_data = train_test_split(\n",
    "        csv, test_size=1-train_ratio, random_state=seed)\n",
    "    test_data, val_data = train_test_split(\n",
    "        testval_data, test_size=0.5, random_state=seed)\n",
    "\n",
    "    # 将新的训练集和测试集分别保存为csv文件\n",
    "    train_path = path.join(dataset_path, \"DiTing330km_train.csv\")\n",
    "    test_path = path.join(dataset_path, \"DiTing330km_test.csv\")\n",
    "    val_path = path.join(dataset_path, \"DiTing330km_validation.csv\")\n",
    "    train_data.to_csv(train_path, index=False)\n",
    "    test_data.to_csv(test_path, index=False)\n",
    "    val_data.to_csv(val_path, index=False)\n",
    "\n",
    "\n",
    "# 调用函数，传入清洗后csv和训练集占比\n",
    "split_csv(csv)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2724185\n"
     ]
    }
   ],
   "source": [
    "print(len(csv))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[1], line 2\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mtqdm\u001b[39;00m \u001b[39mimport\u001b[39;00m tqdm\n\u001b[1;32m----> 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mutils\u001b[39;00m \u001b[39mimport\u001b[39;00m plot3C\n\u001b[0;32m      3\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mdataset\u001b[39;00m \u001b[39mimport\u001b[39;00m PPDataset\n\u001b[0;32m      6\u001b[0m ppd \u001b[39m=\u001b[39m PPDataset(dataset_path, \u001b[39m\"\u001b[39m\u001b[39mDiTing330km_total_wash.csv\u001b[39m\u001b[39m\"\u001b[39m)\n",
      "File \u001b[1;32me:\\code\\phase-picker\\src\\utils.py:4\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mpandas\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mpd\u001b[39;00m\n\u001b[0;32m      3\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mnumpy\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mnp\u001b[39;00m\n\u001b[1;32m----> 4\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39msignal\u001b[39;00m \u001b[39mimport\u001b[39;00m find_peaks\n\u001b[0;32m      7\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mplot3C\u001b[39m(d, title\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39m'\u001b[39m):\n\u001b[0;32m      8\u001b[0m     plt\u001b[39m.\u001b[39mfigure(figsize\u001b[39m=\u001b[39m(\u001b[39m6\u001b[39m,\u001b[39m3\u001b[39m))\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\site-packages\\scipy\\signal\\__init__.py:323\u001b[0m\n\u001b[0;32m    314\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_spline\u001b[39;00m \u001b[39mimport\u001b[39;00m (  \u001b[39m# noqa: F401\u001b[39;00m\n\u001b[0;32m    315\u001b[0m     cspline2d,\n\u001b[0;32m    316\u001b[0m     qspline2d,\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m    319\u001b[0m     symiirorder2,\n\u001b[0;32m    320\u001b[0m )\n\u001b[0;32m    322\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_bsplines\u001b[39;00m \u001b[39mimport\u001b[39;00m \u001b[39m*\u001b[39m\n\u001b[1;32m--> 323\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_filter_design\u001b[39;00m \u001b[39mimport\u001b[39;00m \u001b[39m*\u001b[39m\n\u001b[0;32m    324\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_fir_filter_design\u001b[39;00m \u001b[39mimport\u001b[39;00m \u001b[39m*\u001b[39m\n\u001b[0;32m    325\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_ltisys\u001b[39;00m \u001b[39mimport\u001b[39;00m \u001b[39m*\u001b[39m\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\site-packages\\scipy\\signal\\_filter_design.py:16\u001b[0m\n\u001b[0;32m     13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mnumpy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mpolynomial\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mpolynomial\u001b[39;00m \u001b[39mimport\u001b[39;00m polyval \u001b[39mas\u001b[39;00m npp_polyval\n\u001b[0;32m     14\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mnumpy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mpolynomial\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mpolynomial\u001b[39;00m \u001b[39mimport\u001b[39;00m polyvalfromroots\n\u001b[1;32m---> 16\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mscipy\u001b[39;00m \u001b[39mimport\u001b[39;00m special, optimize, fft \u001b[39mas\u001b[39;00m sp_fft\n\u001b[0;32m     17\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mspecial\u001b[39;00m \u001b[39mimport\u001b[39;00m comb\n\u001b[0;32m     18\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39m_lib\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39m_util\u001b[39;00m \u001b[39mimport\u001b[39;00m float_factorial\n",
      "File \u001b[1;32m<frozen importlib._bootstrap>:1055\u001b[0m, in \u001b[0;36m_handle_fromlist\u001b[1;34m(module, fromlist, import_, recursive)\u001b[0m\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\site-packages\\scipy\\__init__.py:211\u001b[0m, in \u001b[0;36m__getattr__\u001b[1;34m(name)\u001b[0m\n\u001b[0;32m    209\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__getattr__\u001b[39m(name):\n\u001b[0;32m    210\u001b[0m     \u001b[39mif\u001b[39;00m name \u001b[39min\u001b[39;00m submodules:\n\u001b[1;32m--> 211\u001b[0m         \u001b[39mreturn\u001b[39;00m _importlib\u001b[39m.\u001b[39;49mimport_module(\u001b[39mf\u001b[39;49m\u001b[39m'\u001b[39;49m\u001b[39mscipy.\u001b[39;49m\u001b[39m{\u001b[39;49;00mname\u001b[39m}\u001b[39;49;00m\u001b[39m'\u001b[39;49m)\n\u001b[0;32m    212\u001b[0m     \u001b[39melse\u001b[39;00m:\n\u001b[0;32m    213\u001b[0m         \u001b[39mtry\u001b[39;00m:\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\importlib\\__init__.py:127\u001b[0m, in \u001b[0;36mimport_module\u001b[1;34m(name, package)\u001b[0m\n\u001b[0;32m    125\u001b[0m             \u001b[39mbreak\u001b[39;00m\n\u001b[0;32m    126\u001b[0m         level \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m1\u001b[39m\n\u001b[1;32m--> 127\u001b[0m \u001b[39mreturn\u001b[39;00m _bootstrap\u001b[39m.\u001b[39;49m_gcd_import(name[level:], package, level)\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\site-packages\\scipy\\optimize\\__init__.py:413\u001b[0m\n\u001b[0;32m    411\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_nnls\u001b[39;00m \u001b[39mimport\u001b[39;00m nnls\n\u001b[0;32m    412\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_basinhopping\u001b[39;00m \u001b[39mimport\u001b[39;00m basinhopping\n\u001b[1;32m--> 413\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_linprog\u001b[39;00m \u001b[39mimport\u001b[39;00m linprog, linprog_verbose_callback\n\u001b[0;32m    414\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_lsap\u001b[39;00m \u001b[39mimport\u001b[39;00m linear_sum_assignment\n\u001b[0;32m    415\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_differentialevolution\u001b[39;00m \u001b[39mimport\u001b[39;00m differential_evolution\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\site-packages\\scipy\\optimize\\_linprog.py:22\u001b[0m\n\u001b[0;32m     20\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mwarnings\u001b[39;00m \u001b[39mimport\u001b[39;00m warn\n\u001b[0;32m     21\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_linprog_highs\u001b[39;00m \u001b[39mimport\u001b[39;00m _linprog_highs\n\u001b[1;32m---> 22\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_linprog_ip\u001b[39;00m \u001b[39mimport\u001b[39;00m _linprog_ip\n\u001b[0;32m     23\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_linprog_simplex\u001b[39;00m \u001b[39mimport\u001b[39;00m _linprog_simplex\n\u001b[0;32m     24\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_linprog_rs\u001b[39;00m \u001b[39mimport\u001b[39;00m _linprog_rs\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\site-packages\\scipy\\optimize\\_linprog_ip.py:27\u001b[0m\n\u001b[0;32m     25\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlinalg\u001b[39;00m \u001b[39mimport\u001b[39;00m LinAlgError\n\u001b[0;32m     26\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_optimize\u001b[39;00m \u001b[39mimport\u001b[39;00m OptimizeWarning, OptimizeResult, _check_unknown_options\n\u001b[1;32m---> 27\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_linprog_util\u001b[39;00m \u001b[39mimport\u001b[39;00m _postsolve\n\u001b[0;32m     28\u001b[0m has_umfpack \u001b[39m=\u001b[39m \u001b[39mTrue\u001b[39;00m\n\u001b[0;32m     29\u001b[0m has_cholmod \u001b[39m=\u001b[39m \u001b[39mTrue\u001b[39;00m\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\site-packages\\scipy\\optimize\\_linprog_util.py:9\u001b[0m\n\u001b[0;32m      7\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mwarnings\u001b[39;00m \u001b[39mimport\u001b[39;00m warn\n\u001b[0;32m      8\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_optimize\u001b[39;00m \u001b[39mimport\u001b[39;00m OptimizeWarning\n\u001b[1;32m----> 9\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39moptimize\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39m_remove_redundancy\u001b[39;00m \u001b[39mimport\u001b[39;00m (\n\u001b[0;32m     10\u001b[0m     _remove_redundancy_svd, _remove_redundancy_pivot_sparse,\n\u001b[0;32m     11\u001b[0m     _remove_redundancy_pivot_dense, _remove_redundancy_id\n\u001b[0;32m     12\u001b[0m     )\n\u001b[0;32m     13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mcollections\u001b[39;00m \u001b[39mimport\u001b[39;00m namedtuple\n\u001b[0;32m     15\u001b[0m _LPProblem \u001b[39m=\u001b[39m namedtuple(\u001b[39m'\u001b[39m\u001b[39m_LPProblem\u001b[39m\u001b[39m'\u001b[39m,\n\u001b[0;32m     16\u001b[0m                         \u001b[39m'\u001b[39m\u001b[39mc A_ub b_ub A_eq b_eq bounds x0 integrality\u001b[39m\u001b[39m'\u001b[39m)\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\site-packages\\scipy\\optimize\\_remove_redundancy.py:9\u001b[0m\n\u001b[0;32m      7\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mnumpy\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mnp\u001b[39;00m\n\u001b[0;32m      8\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlinalg\u001b[39;00m \u001b[39mimport\u001b[39;00m svd\n\u001b[1;32m----> 9\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlinalg\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39minterpolative\u001b[39;00m \u001b[39mimport\u001b[39;00m interp_decomp\n\u001b[0;32m     10\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mscipy\u001b[39;00m\n\u001b[0;32m     11\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlinalg\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mblas\u001b[39;00m \u001b[39mimport\u001b[39;00m dtrsm\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\site-packages\\scipy\\linalg\\interpolative.py:385\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[39m#******************************************************************************\u001b[39;00m\n\u001b[0;32m      2\u001b[0m \u001b[39m#   Copyright (C) 2013 Kenneth L. Ho\u001b[39;00m\n\u001b[0;32m      3\u001b[0m \u001b[39m#\u001b[39;00m\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m     29\u001b[0m \n\u001b[0;32m     30\u001b[0m \u001b[39m# Python module for interfacing with `id_dist`.\u001b[39;00m\n\u001b[0;32m     32\u001b[0m \u001b[39mr\u001b[39m\u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m     33\u001b[0m \u001b[39m======================================================================\u001b[39;00m\n\u001b[0;32m     34\u001b[0m \u001b[39mInterpolative matrix decomposition (:mod:`scipy.linalg.interpolative`)\u001b[39;00m\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m    382\u001b[0m \n\u001b[0;32m    383\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m--> 385\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlinalg\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39m_interpolative_backend\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39m_backend\u001b[39;00m\n\u001b[0;32m    386\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mnumpy\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mnp\u001b[39;00m\n\u001b[0;32m    387\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39msys\u001b[39;00m\n",
      "File \u001b[1;32mc:\\ProgramData\\Miniconda3\\lib\\site-packages\\scipy\\linalg\\_interpolative_backend.py:34\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[39m#******************************************************************************\u001b[39;00m\n\u001b[0;32m      2\u001b[0m \u001b[39m#   Copyright (C) 2013 Kenneth L. Ho\u001b[39;00m\n\u001b[0;32m      3\u001b[0m \u001b[39m#\u001b[39;00m\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m     27\u001b[0m \u001b[39m#   POSSIBILITY OF SUCH DAMAGE.\u001b[39;00m\n\u001b[0;32m     28\u001b[0m \u001b[39m#******************************************************************************\u001b[39;00m\n\u001b[0;32m     30\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m     31\u001b[0m \u001b[39mDirect wrappers for Fortran `id_dist` backend.\u001b[39;00m\n\u001b[0;32m     32\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m---> 34\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlinalg\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39m_interpolative\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39m_id\u001b[39;00m\n\u001b[0;32m     35\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mnumpy\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mnp\u001b[39;00m\n\u001b[0;32m     37\u001b[0m _RETCODE_ERROR \u001b[39m=\u001b[39m \u001b[39mRuntimeError\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39mnonzero return code\u001b[39m\u001b[39m\"\u001b[39m)\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "from tqdm import tqdm\n",
    "from utils import plot3C\n",
    "from dataset import PPDataset\n",
    "\n",
    "\n",
    "ppd = PPDataset(dataset_path, \"DiTing330km_total_wash.csv\")\n",
    "\n",
    "ps=[]\n",
    "for r in tqdm(csv.iterrows()):\n",
    "    # print(r)\n",
    "    r=r[1]\n",
    "    ps.append(int(r['s_pick'])-int(r['p_pick']))\n",
    "    # if(int(r['s_pick'])-int(r['p_pick']) > 6000):\n",
    "    if(int(r['s_pick'])>8900):\n",
    "        print(r)\n",
    "        plot3C(ppd.__getitem__(r['Unnamed: 0.1'])[0])\n",
    "        plot3C(ppd.__getitem__(r['Unnamed: 0.1'])[0][:,int(r['p_pick'])-500:int(r['p_pick'])+500])\n",
    "\n",
    "print(min(ps), max(ps))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.15"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "19d1d53a962d236aa061289c2ac16dc8e6d9648c89fe79f459ae9a3493bc67b4"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
